package cn.nexttec.noteplayer.injection

import android.content.Context
import cn.nexttec.noteplayer.databases.NoteDatabase
import cn.nexttec.noteplayer.databases.dao.NoteDao
import cn.nexttec.noteplayer.databases.dao.PlayRecordDao
import cn.nexttec.noteplayer.databases.dao.VideoFileDao
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
class DatabaseModule {

    @Singleton
    @Provides
    fun provideDatabase(@ApplicationContext context: Context): NoteDatabase {
        return NoteDatabase.get(context)
    }

    @Singleton
    @Provides
    fun provideVideoFileDao(database: NoteDatabase): VideoFileDao {
        return database.getVideoFileDao()
    }

    @Singleton
    @Provides
    fun provideRecordDao(database: NoteDatabase): PlayRecordDao {
        return database.getPlayRecordDao()
    }

    @Singleton
    @Provides
    fun provideNoteDao(database: NoteDatabase):NoteDao{
        return database.getNoteDao()
    }

}